import { Controller, Get, Delete, Post, Put, Body, Param } from "@nestjs/common";
import { RoleService } from "./role.service";
import { ApiTags, ApiOperation } from "@nestjs/swagger";
import { RoleDto } from "./role.dto";

@Controller('role')
@ApiTags('角色')
export class RoleController{
    constructor(
        private readonly roleService:RoleService
    ){}
    
    @Get()
    @ApiOperation({summary:'查询角色'})
    async find(){
        return await this.roleService.find();
    }
    @Delete(':id')
    @ApiOperation({summary:'根据id删除用户'})
    async remove(@Param('id') roleId){
        return await this.roleService.remove(roleId)
    }

    @Post()
    @ApiOperation({summary:'更改用户'})
    async update(@Body() role:RoleDto){
        return await this.roleService.update(role);
    }
    
    @Put()
    @ApiOperation({summary:'新增用户'})
    async add(@Body() role:RoleDto){
        return await this.roleService.add(role)
    }
}